package com.contain2;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * 不同控制：最好直接将新生成的容器传递给适当的同步方法，这样就不会有任何机会暴漏出不同步的版本
 * 
 * @author Administrator
 *
 */
public class Synchronization {

	public static void main(String[] args) {
		Collection<String> c = Collections
				.synchronizedCollection(new ArrayList<String>());
		List<String> list = Collections
				.synchronizedList(new ArrayList<String>());
		Set<String> s = Collections.synchronizedSet(new HashSet<String>());
		Set<String> ss = Collections
				.synchronizedSortedSet(new TreeSet<String>());
		Map<String, String> m = Collections
				.synchronizedMap(new HashMap<String, String>());
		Map<String, String> sm = Collections
				.synchronizedSortedMap(new TreeMap<String, String>());
	}

}
